#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
class SegmentTree
{
    class Node
    {
    public:
        int ld,rd;
        int w;
        Node *lc,*rc;
        void set(int a,int b,int c){ld=a,rd=b,w=c;}
    };
    static const int MAXN=100100;
public:
    Node* node;
    int cnt;
    SegmentTree()
    {
        node=new Node[MAXN*2+10];
    }
    void init(int n)
    {
        cnt=1;
        build(node,1,n);
    }
    void build(Node *nt,int a,int b)
    {
        nt->set(a,b,0);
        int mid=(a+b)/2;
        if(a<b)
        {
            nt->lc=&node[cnt++];
            build(nt->lc,a,mid);
            nt->rc=&node[cnt++];
            build(nt->rc,mid+1,b);
        }
    }
    void set(Node *nt,int a,int c)
    {
        int mid;
        while(1)
        {
            nt->w+=c;
            if(nt->ld==nt->rd) break;
            mid=(nt->ld+nt->rd)/2;
            if(mid<a) nt=nt->rc;
            else nt=nt->lc;
        }
    }
    void set(int a){set(node,a,1);}
    void del(int a){set(node,a,-1);}
    int query(int k)
    {
        int t;
        Node *nt=node;
        while(nt->ld!=nt->rd)
        {
            if(nt->lc->w<k)
                k-=nt->lc->w,nt=nt->rc;
            else nt=nt->lc;
        }
        return nt->ld;
    }
};

struct area
{
    int st,ed,k;
    int p;
};
area ar[50100];
int res[50100],map[100100];
int aa[100100],*ap[100100];
bool cmp(int *a,int *b){return *a<*b;}
bool cmp1(area a,area b){return a.st<b.st;}
int main()
{
    int n,m;
    SegmentTree t;
    ar[0].ed=-1,ar[0].st=0;
    while(cin>>n>>m)
    {
        t.init(n);
        for(int i=1;i<=n;i++) scanf("%d",&aa[i]),ap[i]=aa+i;
        sort(ap+1,ap+n+1,cmp);
        for(int i=1;i<=n;i++) map[i]=*ap[i],*ap[i]=i;
        for(int i=1;i<=m;i++) scanf("%d%d%d",&ar[i].st,&ar[i].ed,&ar[i].k),ar[i].p=i;
        sort(ar+1,ar+1+m,cmp1);
        for(int i=1;i<=m;i++)
        {
            if(ar[i-1].ed>ar[i].st)
            {
                for(int j=ar[i-1].st;j<ar[i].st;j++) t.del(aa[j]);
                for(int j=ar[i-1].ed+1;j<=ar[i].ed;j++) t.set(aa[j]);
            }
            else
            {
                for(int j=ar[i-1].st;j<=ar[i-1].ed;j++) t.del(aa[j]);
                for(int j=ar[i].st;j<=ar[i].ed;j++) t.set(aa[j]);
            }
            res[ar[i].p]=map[t.query(ar[i].k)];
        }
        for(int i=1;i<=m;i++)cout<<res[i]<<endl;
    }
    return 0;
}
